//
//  Movie2CollectionViewCell.m
//  UI_元旦豆瓣电影
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "Movie2CollectionViewCell.h"
#import "MovieModel.h"
#import "UIImageView+WebCache.h"
@interface Movie2CollectionViewCell ()

@property (nonatomic, retain) UIImageView *imgV;
@property (nonatomic, retain) UILabel *label;

@end

@implementation Movie2CollectionViewCell

- (void)dealloc {
    [_imgV release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)setModel2:(MovieModel *)model2 {
    if (_model2 != model2) {
        [_model2 release];
        _model2 = [model2 retain];
        [self fuZhi];
    }
}

- (void)fuZhi {
    [_imgV sd_setImageWithURL:[NSURL URLWithString:_model2.image]];
    _label.text = _model2.title;
}

- (void)createCell {
    self.imgV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imgV];
    [_imgV release];
    
    self.label = [[UILabel alloc] init];
    [self.contentView addSubview:_label];
    _label.textAlignment = NSTextAlignmentCenter;
    _label.backgroundColor = [UIColor whiteColor];
    _label.alpha = 0.5;
    [_label release];
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _imgV.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height);
    _label.frame = CGRectMake(0, layoutAttributes.frame.size.height - 30, layoutAttributes.frame.size.width, 30);
}


@end
